/* @license GPL-2.0-or-later https://www.drupal.org/licensing/faq */ (function($,Drupal,once,drupalSettings){'use strict';if(typeof drupalSettings.cvJqueryValidateOptions==='undefined')drupalSettings.cvJqueryValidateOptions={};if(drupalSettings.clientside_validation_jquery.force_validate_on_blur)drupalSettings.cvJqueryValidateOptions.onfocusout=function(element){this.element(element);};$.extend($.validator.messages,drupalSettings.clientside_validation_jquery.messages);var _urlValidation=$.validator.methods.url;$.validator.methods.url=function(value,element){return _urlValidation.call(this,value,element)||/^(public|private):\/\//.test(value);};Drupal.behaviors.cvJqueryValidate={attach:function(context){if(typeof Drupal.Ajax!=='undefined')if(typeof Drupal.Ajax.prototype.beforeSubmitCVOriginal==='undefined'){var validateAll=2;try{validateAll=drupalSettings.clientside_validation_jquery.validate_all_ajax_forms;}catch(e){}Drupal.Ajax.prototype.beforeSubmitCVOriginal=Drupal.Ajax.prototype.beforeSubmit;Drupal.Ajax.prototype.beforeSubmit=function(form_values,element_settings,options){if(typeof this.$form!=='undefined'&&(validateAll===1||$(this.element).hasClass('cv-validate-before-ajax'))&&$(this.element).attr("formnovalidate")==undefined){$(this.$form).removeClass('ajax-submit-prevented');$(this.$form).validate();if(!($(this.$form).valid())){this.ajaxing=false;$(this.$form).addClass('ajax-submit-prevented');return false;}}return this.beforeSubmitCVOriginal.apply(this,arguments);};}$(document).trigger('cv-jquery-validate-options-update',drupalSettings.cvJqueryValidateOptions);once('cvJqueryValidate','body form').forEach(function(element){$(element).validate(drupalSettings.cvJqueryValidateOptions);});}};})(jQuery,Drupal,once,drupalSettings);; (function($,Drupal,drupalSettings){Drupal.behaviors.commentByViewer={attach(context){const currentUserID=parseInt(drupalSettings.user.uid,10);$('[data-comment-user-id]').filter(function(){return (parseInt(this.getAttribute('data-comment-user-id'),10)===currentUserID);}).addClass('by-viewer');}};})(jQuery,Drupal,drupalSettings);; "use strict";var detailRecipe=document.querySelector(".recipeDetail__v3");if(detailRecipe){var getHeaderHeightV3=function getHeaderHeightV3(element){return element.offsetHeight;};var fixarElemento=function fixarElemento(elementoAlvo,headerHeight){var posicaoInicial=elementoAlvo.offsetTop,alturaElemento=elementoAlvo.offsetHeight,elV3=detailRecipe.querySelector(".recipeDetail__top .recipeDetail__actions--fixeDesk");function atualizarPosicao(){var posicaoScroll=window.pageYOffset,posicaoTopo=document.documentElement.scrollTop,posicaoInicialV3=posicaoInicial+headerHeight;if(posicaoScroll>=posicaoInicialV3){elV3.style.position="fixed";elV3.style.top=87+"px";elV3.classList.add("scroll");}else{elV3.style.top=-15+"px";elV3.classList.remove("scroll");}}window.addEventListener("scroll",atualizarPosicao);};if(!isDesktop()){var tagElem=document.querySelector(".recipeDetail__actions .actions"),headerV3recipe=document.querySelector(".headerV3");fixarElemento(tagElem,getHeaderHeightV3(headerV3recipe));}}; "use strict";jQuery(function($){$(document).ready(function(){var $headerV3=$("#headerV3");if($headerV3){var desmarcarOutros=function desmarcarOutros(checkbox){$("input[name=\"".concat(checkbox.name,"\"]"),$headerV3).not(checkbox).prop("checked",false);};var handleCheckboxChanges=function handleCheckboxChanges(checkboxData){checkboxData.forEach(function(data){$(data.checkboxInput).change(function(){$(data.targetElementSelector).toggleClass(data.className,this.checked);});});};var $document=$(document);$document.scroll(function(){$headerV3.toggleClass("scrolled",$document.scrollTop()>=147);});if(!isDesktop()){var checkboxData=[{checkboxInput:"#menu-burger",targetElementSelector:"html",className:"lock-scroll"},{checkboxInput:"#user",targetElementSelector:"html",className:"lock-scroll"},{checkboxInput:"#user",targetElementSelector:"li.sub-menu",className:"events-none"}];handleCheckboxChanges(checkboxData);$("input[name='burger'], input[name='dropdown-menu']",$headerV3).change(function(){if(this.checked)desmarcarOutros(this);});var $btnModal=$(".open-modal-login",$headerV3);if($btnModal.length)$btnModal.click(function(){$("#menu-burger",$headerV3).prop("checked",false);});}else $("#user").change(function(){$("li.sub-menu").toggleClass("events-none",this.checked);});var headerHeight=$headerV3.height();document.documentElement.style.setProperty("--header-height-v3","".concat(headerHeight,"px"));var $sectionLoginV3=$(".section-login");if($sectionLoginV3.length){var sectionLoginHeight=$sectionLoginV3.height();document.documentElement.style.setProperty("--section-login-height-v3","".concat(sectionLoginHeight/16,"rem"));}}});});; "use strict";var shareRecipeDetail=document.querySelector(".recipeDetail__share");if(shareRecipeDetail){var shareIngredients=function shareIngredients(){var conteudo=encodeURIComponent(btnWhats.getAttribute("data-msg")+" "+document.title+":"+"\n\n"+items.join("\n")+"\n\n"+window.location.href);btnWhats.href="https://wa.me/?text="+conteudo;};var ingredients=document.querySelector(".recipeDetail__ingredients");var steps=ingredients.querySelectorAll(".recipeDetail__stepItem");var btnWhats=document.getElementById("whatsapp-share-btt");var items=[];if(steps.length>1)steps.forEach(function(itens){var listIng=itens.querySelectorAll(".recipeDetail__ingredients ul li");var title=itens.querySelector(".hl-3");if(title)items.push("*".concat(title.innerText,"*"));for(var i=0;i4){glideArrows===null||glideArrows===void 0||glideArrows.classList.remove("hidden");glideSlides===null||glideSlides===void 0||glideSlides.classList.remove("fixes");}slidesThumbs.forEach(function(item){item.addEventListener("click",function(){slidesThumbs.forEach(function(i){return i.classList.remove("active");});item.classList.add("active");});});var carouselConfig=_objectSpread(_objectSpread({},defaultSlideConfig),{},{type:"slider",bound:true,perView:4,gap:8,focusAt:0,dragThreshold:false,swipeThreshold:false});var carouselSlider=new Glide(carouselThumbs,carouselConfig);var controlledSlider=carouselThumbs.dataset.bindcontrols;if(carouselThumbs.id)carouselsArr["#".concat(carouselThumbs.id)]=carouselSlider;slidesThumbs.forEach(function(slide,index){slide.addEventListener("click",function(event){event.stopPropagation();var target="=".concat(index);hb_gotoSlide(carouselSlider,target).then(function(){if(slidersArr[controlledSlider])hb_gotoSlide(slidersArr[controlledSlider],target);});});});carouselSlider.mount();}}; "use strict";function setFavoriteRecipes(){var event=new Event("setFavoriteRecipes");document.dispatchEvent(event);addEventOpenModalLogin();}(function($,Drupal,drupalSettings){Drupal.behaviors.cookit_actions={attach:function attach(context,settings){var save={init:function init(){var othis=this;if(!isLogged())return;othis.csrftoken=drupalSettings.csrftoken;othis.createModal();othis.setFavorite();othis.addEventListeners();},addEventListeners:function addEventListeners(){var othis=this;document.addEventListener("setFavoriteRecipes",function(e){e.preventDefault();othis.addEventListeners();othis.setFavorite();});document.querySelectorAll("[nid-id]").forEach(function(el){if(el.getAttribute("data-click-added"))return;el.setAttribute("data-click-added","true");el.addEventListener("click",function(e){e.preventDefault();if(el.classList.contains("active"))othis.removeFavorite(el);else othis.addFavorite(el);});});document.querySelectorAll("[cooked-nid-id]").forEach(function(el){if(el.getAttribute("data-click-added"))return;el.setAttribute("data-click-added","true");el.addEventListener("click",function(e){e.preventDefault();if(el.classList.contains("active"))othis.removeFavorite(el);else othis.addAsCooked(el);});});document.querySelectorAll(".saveRecipe__newFoodList").forEach(function(el){if(el.getAttribute("data-submit-added"))return;el.setAttribute("data-submit-added","true");el.addEventListener("submit",function(e){e.preventDefault();var input=document.querySelector(".saveRecipe__newFoodList input");var value=input.value;value=value.replace(/<\/?[^>]+(>|$)/g,"");var categoryName=value.replace(/\s/g," ");if(!categoryName)categoryName="Invalid text";othis.updateList({category_name:categoryName,entity_id:input.getAttribute("data-entity-id")},function(){othis.setFavorite();notify.add("

"+Drupal.t("Guardada en")+" \u201C"+categoryName+"\u201D

");modal.close();});});});},getCategories:function getCategories(callback){var othis=this;jQuery.ajax({method:"GET",url:"/v1/favorite/categories",headers:{"X-CSRF-Token":othis.csrftoken},success:function success(data){othis.categoriesList=data;var tidFavorite=data.filter(function(item){return item.name==Drupal.t("Mis favoritas");});if(tidFavorite.length>0)othis.tidFavorite=tidFavorite[0].tid;var tidCooked=data.filter(function(item){return item.name==Drupal.t("Las que ya cocin\xE9");});if(tidCooked.length>0)othis.tidCooked=tidCooked[0].tid;callback();}});},setFavorite:function setFavorite(){var othis=this;showLoading();othis.getCategories(function(){jQuery.ajax({method:"GET",url:"/v1/favorite/list",headers:{"X-CSRF-Token":othis.csrftoken},success:function success(data){document.querySelectorAll("[nid-id], [cooked-nid-id]").forEach(function(el){el.classList.remove("active");});if(data&&data.length>0)data.forEach(function(item){document.querySelectorAll("[nid-id=\""+item.nid+"\"]").forEach(function(el){el.classList.add("active");el.setAttribute("data-entity-id",item.entity_id);});document.querySelectorAll("[cooked-nid-id=\""+item.nid+"\"]").forEach(function(el){el.setAttribute("data-entity-id",item.entity_id);if(item.tid==othis.tidCooked)el.classList.add("active");});});hideLoading();}});});},addFavorite:function addFavorite(el){var othis=this;showLoading();jQuery.ajax({method:"POST",url:"/v1/favorite/add",headers:{"X-CSRF-Token":othis.csrftoken},data:{recipe_id:el.getAttribute("nid-id"),category_id:othis.tidFavorite},success:function success(data){if(data.result){othis.entityId=data.entity_id;othis.generateModals();othis.setFavorite();notify.add("

"+Drupal.t("Guardada")+"

"+Drupal.t("Agregar a recetario")+"");}else alert("Internal error!");hideLoading();}});},removeFavorite:function removeFavorite(el){var othis=this;showLoading();jQuery.ajax({method:"POST",url:"/v1/favorite/remove",headers:{"X-CSRF-Token":othis.csrftoken},data:{recipe_id:el.getAttribute("nid-id")||el.getAttribute("cooked-nid-id")},success:function success(data){if(data.result){othis.setFavorite();notify.add("

"+Drupal.t("Removido")+"

");}else alert("Internal error");hideLoading();}});},updateList:function updateList(dataObject,callback){var othis=this;showLoading();jQuery.ajax({method:"POST",url:"/v1/favorite/update",headers:{"X-CSRF-Token":othis.csrftoken},data:dataObject,success:function success(data){if(data.result)callback();else alert("Internal error!");hideLoading();}});},addAsCooked:function addAsCooked(el){var othis=this;showLoading();jQuery.ajax({method:"POST",url:"/v1/cooked",headers:{"X-CSRF-Token":othis.csrftoken},data:{recipe_id:el.getAttribute("cooked-nid-id"),entity_id:el.getAttribute("data-entity-id"),category_id:othis.tidCooked},success:function success(data){if(data.result){othis.setFavorite();othis.entityId=data.entity_id;othis.generateModals();notify.add("

"+Drupal.t("Cozinhada")+"");}else alert("Internal error!");hideLoading();}});},createModal:function createModal(){var modalList=document.createElement("div");modalList.setAttribute("id","saveRecipeList");modalList.setAttribute("class","modal modal--right saveRecipe");modalList.innerHTML="

"+Drupal.t("Back")+"

"+Drupal.t("Agregar a recetario")+"

";var modalForm=document.createElement("div");modalForm.setAttribute("id","saveRecipeForm");modalForm.setAttribute("class","modal modal--right saveRecipe");modalForm.innerHTML="

"+Drupal.t("Nuevo recetario")+"

";document.querySelector("body").appendChild(modalList);document.querySelector("body").appendChild(modalForm);},generateModals:function generateModals(){var othis=this;if(othis.categoriesList==undefined)return;var list=document.querySelector(".saveRecipe__list");var input=document.querySelector(".saveRecipe__newFoodList input");input.setAttribute("data-entity-id",othis.entityId);var btnsUsers=document.querySelectorAll(".foodListCard--user");if(btnsUsers)btnsUsers.forEach(function(btn){btn.remove();});othis.categoriesList.forEach(function(item){var btnCategory=document.createElement("button");btnCategory.setAttribute("data-entity-id",othis.entityId);btnCategory.setAttribute("data-nid",item.tid);btnCategory.className="foodListCard foodListCard--user";var icon=document.createElement("i");var iconList=item.tid==othis.tidFavorite?"svg svg-save":"svg svg-list";icon.className=iconList;var divIcon=document.createElement("div");divIcon.className="foodListCard__icon";var divText=document.createElement("div");divText.className="foodListCard__text";var h2=document.createElement("h2");h2.className="name";h2.innerText=item.name;divText.appendChild(h2);divIcon.appendChild(icon);btnCategory.appendChild(divIcon);btnCategory.appendChild(divText);list.appendChild(btnCategory);});othis.foodListCards=document.querySelectorAll(".foodListCard[data-entity-id][data-nid]");othis.foodListCards.forEach(function(el){el.addEventListener("click",function(e){e.preventDefault();othis.updateList({entity_id:el.getAttribute("data-entity-id"),category_id:el.getAttribute("data-nid"),cooked:el.getAttribute("data-nid")==othis.tidCooked},function(){notify.add("

"+Drupal.t("Guardada en")+" \u201C"+el.querySelector(".name").textContent+"\u201D

");othis.setFavorite();modal.close();});});});}};save.init();}};})(jQuery,Drupal,drupalSettings);var share={init:function init(){var othis=this;othis.shareButton=document.querySelectorAll(".shareButton");othis.addEventListener();document.querySelectorAll("#btnCopy").forEach(function(el){el.addEventListener("click",function(e){e.preventDefault();var url=el.getAttribute("data-url");othis.copyToClipboard(url);});});},addEventListener:function addEventListener(){var othis=this;othis.shareButton.forEach(function(el){el.addEventListener("click",function(e){othis.openShare(el);});});},openShare:function openShare(shareButton){var othis=this;if(navigator.canShare&&screen.width<=576)navigator.share({title:document.title,text:document.title,url:location.href}).then(function(){return console.log("Successful share");})["catch"](function(error){console.log(error);});else{var shareOptions=shareButton.querySelector(".shareOptions");if(shareButton.classList.contains("active")){shareButton.classList.remove("active");shareOptions.classList.remove("active");return;}shareButton.classList.add("active");shareOptions.classList.add("active");othis.closeShare(shareButton);}},closeShare:function closeShare(shareButton){window.addEventListener("click",function(e){if(!e.target.closest(".shareButton")){var shareOptions=shareButton.querySelector(".shareOptions");if(shareButton.classList.contains("active")){shareButton.classList.remove("active");shareOptions.classList.remove("active");return;}}});},copyToClipboard:function copyToClipboard(el){var textArea=document.createElement("textarea");textArea.value=el;document.body.appendChild(textArea);textArea.select();try{var successful=document.execCommand("copy");var msg=successful?"Copied link":"Error copy link";notify.add("

"+Drupal.t(msg)+"

");}catch(err){console.log("Oops, unable to copy");}document.body.removeChild(textArea);}};share.init();; "use strict";function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o;}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o;},_typeof(o);}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable;})),t.push.apply(t,o);}return t;}function _objectSpread(e){for(var r=1;r